package org.jbp.timelapse;

import android.content.Context;
import android.text.Html;
import android.text.method.ScrollingMovementMethod;
import android.util.AttributeSet;
import android.widget.TextView;

public class LogTextView extends TextView
{
	public LogTextView(Context context)
	{
		super(context);
		setMovementMethod(new ScrollingMovementMethod());
		setMaxLines(24);
	}
	
	public LogTextView(Context context, AttributeSet attrs)
	{
		super(context, attrs);
		setMovementMethod(new ScrollingMovementMethod());
		setMaxLines(24);
	}
	
	public LogTextView(Context context, AttributeSet attrs, int defStyle)
	{
		super(context, attrs, defStyle);
		setMovementMethod(new ScrollingMovementMethod());
		setMaxLines(24);
	}
	
	public void info(String message)
	{
		appendMessage(message, TimeLapseConstants.COLOR_INFO);
	}
	
	public void error(String message)
	{
		appendMessage(message, TimeLapseConstants.COLOR_ERROR);
	}
	
	private void appendMessage(String message, String color)
	{
		append(Html.fromHtml("<font color='"+color+"'>"+message+"</font><br/>"));
	}
}